import { IToolBase } from '../tools-base';
import { createElement } from '../../../utils/dom-helper';
export function Single(opt: {icon: string, index?: number, title?: string, command?: string}) {
    return function(target: any, propertyKey: string) {
        if(target.constructor.hasOwnProperty('__icon_init__') == false) {
            Object.defineProperty(target.constructor, '__icon_init__', {
                enumerable: false,
                value: []
            });
        }
        if(target.constructor.hasOwnProperty('__icon_init__') == false) {
            Object.defineProperty(target.constructor, '__icon_init__', {
                enumerable: false,
                value: []
            });
        }
        (<any>target).constructor['__icon_init__'].push(function (toolInstance: IToolBase) {
                let ele = createElement('span', {'class': `icon iconfont icon-${opt.icon}`, title: opt.title});
                ele.addEventListener('click', (<any>toolInstance)[propertyKey].bind(toolInstance));
                toolInstance.container.appendChild(ele);
        });
    }
}